package com.kaifamiao.time;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class ZonedDateTimeInstance {

    public static void main(String[] args) {

        LocalDateTime datetime = LocalDateTime.now();
        System.out.println( datetime );

        ZoneId zone = ZoneId.of( "Asia/Chongqing" );
        // 根据 LocalDateTime 实例 获得 携带了时区信息 的 ZonedDateTime实例
        ZonedDateTime zdt = datetime.atZone( zone );
        System.out.println( zdt );

        System.out.println( datetime.atZone( ZoneId.of( "Europe/Monaco" ) ) );

        ZonedDateTime current = ZonedDateTime.now();
        System.out.println( current );

        ZonedDateTime x = ZonedDateTime.of( datetime, ZoneId.of( "America/Shiprock" ) );
        System.out.println( x );

        x = ZonedDateTime.ofInstant( Instant.now() , ZoneId.systemDefault() );
        System.out.println( x );
    }

}
